'use strict';

const tree = require('../lib/mongoose/plugin_tree');
const findOrCreate = require('../lib/mongoose/plugin_findorcreate');

module.exports = mongoose => {

  const schema = new mongoose.Schema({
    name: { type: String },
    node: { type: String },
    space: { type: mongoose.Schema.Types.ObjectId, ref: 'Space' },
  });

  schema.plugin(tree);
  schema.plugin(findOrCreate);

  return mongoose.model('Permit', schema);
};
